﻿namespace StudyCompanion.Commons.Extension;

public static class ObjectExtension
{
    /// <summary>
    ///     将object转换为bool类型信息。
    /// </summary>
    /// <param name="o">object。</param>
    /// <param name="t">默认值。</param>
    /// <returns>bool。</returns>
    public static bool ToBool(this object o, bool t = default)
    {
        if (!bool.TryParse(o.ToString(), out var info)) info = t;
        return info;
    }
}